﻿using cpe.cpein.SERVER.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace cpe.cpein.SERVER.Tools
{
    public static partial class ObjectConverter
    {
        /// <summary>
        /// Function used to convert a WS GroupType to a Data GroupType.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static DATA.GroupType GroupTypeConverter(GroupType GroupType)
        {
            if (GroupType == null)
                return null;

            return new DATA.GroupType()
            {
                grt_id = GroupType.Id,
                grt_label = GroupType.Label,
                grt_isdeleted = GroupType.IsDeleted,
            };
        }

        /// <summary>
        /// Function used to convert a Data GroupType to a WS GroupType.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static GroupType GroupTypeConverter(DATA.GroupType GroupType)
        {
            if (GroupType == null)
                return null;

            return new GroupType()
            {
                Id = GroupType.grt_id,
                Label = GroupType.grt_label,
                IsDeleted = GroupType.grt_isdeleted,
            };
        }

        /// <summary>
        /// Function used to convert a list of Data GroupTypes to a List of WS GroupTypes.
        /// </summary>
        /// <param name="GroupTypes"></param>
        /// <returns></returns>
        public static List<GroupType> GroupTypeConverter(List<DATA.GroupType> GroupTypes)
        {
            List<GroupType> res = new List<GroupType>();
            foreach (DATA.GroupType us in GroupTypes)
                res.Add(Tools.ObjectConverter.GroupTypeConverter(us));

            return res;
        }

        /// <summary>
        /// Function used to convert a list of WS GroupTypes to a List of Data GroupTypes.
        /// </summary>
        /// <param name="GroupTypes"></param>
        /// <returns></returns>
        public static List<DATA.GroupType> GroupTypeConverter(List<GroupType> GroupTypes)
        {
            List<DATA.GroupType> res = new List<DATA.GroupType>();
            foreach (GroupType us in GroupTypes)
                res.Add(Tools.ObjectConverter.GroupTypeConverter(us));

            return res;
        }
    }
}